package com.qf.kdgroup.gdbackend.controller;

import com.github.pagehelper.PageInfo;
import com.qf.kdgroup.gdbackend.dto.ResultBean;
import com.qf.kdgroup.gdbackend.entity.Auth;
import com.qf.kdgroup.gdbackend.entity.Role;
import com.qf.kdgroup.gdbackend.service.AuthService;
import com.qf.kdgroup.gdbackend.service.RoleService;
import com.qf.kdgroup.gdbackend.vo.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/role")
@CrossOrigin
public class RoleController {

    @Autowired
    private RoleService roleService;

    @PostMapping("/getList")
    public PageInfo getList(@RequestBody PageVO pageVO){
        return roleService.selectAllByPage(pageVO);
    }

    @DeleteMapping("/delete")
    public ResultBean deleteByRoleId(@RequestBody Role role){

        return roleService.deleteByRoleId(role.getRoleid());
    }

    @PostMapping("/add")
    public ResultBean add(@RequestBody Role role){

        return roleService.add(role);
    }

    @PostMapping("/find")
    public Role findByRoleId(@RequestBody Role role){

        return roleService.findByRoleId(role.getRoleid());
    }

    @PostMapping("/update")
    public ResultBean update(@RequestBody Role role){

        return roleService.update(role);
    }

}
